home *** CD-ROM | disk | FTP | other *** search
/ LiquidLibrary 2005 September / LiquidLibrary 2005 Sep - Disc 1.iso / pc / Portfolio Browser / Filters / PDF / LIB / gs_pfile.ps < prev    next >
Text File  |  2003-01-03  |  4KB  |  118 lines

  1. %    Copyright (C) 1994, 1995 Aladdin Enterprises.  All rights reserved.
  2. % This software is licensed to a single customer by Artifex Software Inc.
  3. % under the terms of a specific OEM agreement.
  4.  
  5. % $RCSfile$ $Revision$
  6. % Runtime support for minimum-space fonts and packed files.
  7.  
  8. % ****** NOTE: This file must be kept consistent with
  9. % ****** packfile.ps and wrfont.ps.
  10.  
  11. % ---------------- Packed file support ---------------- %
  12.  
  13. % A packed file is the concatenation of several file groups, each of which
  14. % is the result of compressing several files concatenated together.
  15. % The packed file begins with a procedure that creates an appropriate
  16. % decoding filter for each file group, as follows:
  17. %    <group-subfile-filter> -proc- <group-decode-filter>
  18. % Thus, accessing an individual file requires 4 parameters:
  19. % the starting address and length of the outer compressed file,
  20. % and the starting address and length of the inner file.
  21. /.packedfilefilter    % <file> <ostart> <olength> <istart> <ilength>
  22.             %   .packedfilefilter <filter>
  23.  { 4 index systemdict begin token pop end 6 1 roll
  24.     % Stack: fproc file ostart olength istart ilength
  25.    4 index 5 -1 roll setfileposition
  26.     % Stack: fproc file olength istart ilength
  27.    4 -2 roll () /SubFileDecode filter
  28.     % Stack: fproc istart ilength ofilter
  29.    4 -1 roll exec
  30.     % Filters don't support setfileposition, so we must skip data
  31.     % by reading it into a buffer.  We rely on the fact that
  32.     % save/restore don't affect file positions.
  33.     % Stack: istart ilength dfilter
  34.    save exch 1000 string
  35.     % Stack: istart ilength save dfilter scratch
  36.    4 index 1 index length idiv { 2 copy readstring pop pop } repeat
  37.    2 copy 0 8 -1 roll 2 index length mod getinterval readstring pop pop pop
  38.     % Stack: ilength save dfilter
  39.    exch restore exch () /SubFileDecode filter
  40.  } bind def
  41.  
  42. % Run a packed library file.
  43. /.runpackedlibfile    % <filename> <ostart> <olength> <istart> <ilength>
  44.             %   .runpackedlibfile
  45.  { 5 -1 roll findlibfile
  46.     { exch pop dup 6 2 roll .packedfilefilter
  47.       currentobjectformat exch 1 setobjectformat run
  48.       setobjectformat closefile
  49.     }
  50.     { 5 1 roll /findlibfile load /undefinedfilename signalerror
  51.     }
  52.    ifelse
  53.  } bind def
  54.  
  55. % ---------------- Compacted font support ---------------- %
  56.  
  57. % Compacted fonts written by wrfont.ps depend on the existence and
  58. % specifications of the procedures and data in this section.
  59.  
  60. /.compactfontdefault mark
  61.     /PaintType 0
  62.     /FontMatrix [0.001 0 0 0.001 0 0] readonly
  63.     /FontType 1
  64.     /Encoding StandardEncoding
  65. .dicttomark readonly def
  66.  
  67. /.checkexistingfont    % <fontname> <uid> <privatesize> <fontsize>
  68.             %   .checkexistingfont
  69.             %   {} (<font> on d-stack)
  70.             % <fontname> <uid> <privatesize> <fontsize>
  71.             %   .checkexistingfont
  72.             %   -save- --restore-- (<font> on d-stack)
  73.  { FontDirectory 4 index .knownget
  74.     { dup /UniqueID .knownget
  75.        { 4 index eq exch /FontType get 1 eq and }
  76.        { pop false }
  77.       ifelse
  78.     }
  79.     { false
  80.     }
  81.    ifelse
  82.     { save /restore load 6 2 roll }
  83.     { {} 5 1 roll }
  84.    ifelse
  85.    dict //.compactfontdefault exch .copydict begin
  86.    dict /Private exch def
  87.    Private begin
  88.      /MinFeature {16 16} def
  89.      /Password 5839 def
  90.      /UniqueID 1 index def
  91.    end
  92.    /UniqueID exch def
  93.    /FontName exch def
  94.  } bind def
  95.  
  96. /.knownEncodings [
  97.    ISOLatin1Encoding
  98.    StandardEncoding
  99.    SymbolEncoding
  100. ] readonly def
  101.  
  102. /.readCharStrings    % <count> <encrypt> .readCharStrings <dict>
  103.  { exch dup dict dup 3 -1 roll
  104.     { currentfile token pop dup type /integertype eq
  105.        { dup -8 bitshift //.knownEncodings exch get exch 255 and get } if
  106.       currentfile token pop dup type /nametype eq
  107.        { 2 index exch get
  108.        }
  109.        {    % Stack: encrypt dict dict key value
  110.      4 index { 4330 exch dup .type1encrypt exch pop } if
  111.      readonly
  112.        }
  113.       ifelse put dup
  114.     }
  115.    repeat pop exch pop
  116.  } bind def
  117.